﻿using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using Kang.Monitor.Wpf.Service;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Kang.Monitor.Wpf.ViewModels
{
    public partial class SerialViewModel : ObservableObject
    {
        public ModbusHelp _modbusHelp { get; set; }

        public SerialViewModel(ModbusHelp modbusHelp)
        { _modbusHelp = modbusHelp; }

        private string msg;

        public string Msg
        {
            get { return msg; }
            set { SetProperty(ref msg, value); }
        }

        [RelayCommand]
        private void SendMsg(string sendMsg)
        {
            //字符串转ushort
            _modbusHelp?.SendMsgModbus((ushort)Convert.ToInt32(sendMsg, 16));
        }
    }
}